package com.ljy.my_study.json转对象;

import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ljy.my_study.json转对象.util.Json2ClassBuilder;
import com.ljy.my_study.json转对象.util.ParamNode;

/** 
* @author James
* @date 2018年8月24日 
*/
public class TestMain {
	private static Map<String,ParamNode> paramMap=new HashMap<>();
	
	public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {

		String jsonStr=" \n" +
				"{\n" +
				"    \"result\":[\n" +
				"        {\n" +
				"            \"head\":2,\n" +
				"            \"pos\":\"NR\",\n" +
				"            \"id\":1,\n" +
				"            \"label\":\"SBV\",\n" +
				"            \"word\":\"小明\"\n" +
				"        }\n" +
				"    ],\n" +
				"    \"success\":true\n" +
				"}";

		String rootBeanName="GetDpChGeneralStanfordRespDTO";
		String packageUrl="com.ut.businessanalysistooltest.core.poi.table.dto";
		String filePath="C:\\Users\\lijunying.UT\\Desktop\\对象";

		ObjectMapper objectMapper=new ObjectMapper();
		Map<String,Object> map=objectMapper.readValue(jsonStr, new TypeReference<Map<String,Object>>() {});
		Json2ClassBuilder.createBeanFile(rootBeanName,(LinkedHashMap<String,Object>)map,
				packageUrl,filePath);
	
	}
}
